<template>
    <div class="mac">
        <ul class="dock">
            <li
                :class="[hoverItem === index ? 'hoverClass item' : 'item']"
                ref="item"
                v-for="(item, index) in list"
                :key="index"
                @click="itemClick($event)"
                @mousemove="itemMousemove($event, index)"
                @mouseleave="dockMouseleave($event)"
            >
                <i :class="item" class="iconfont"></i>
                <!-- {{ item }} -->
            </li>
        </ul>
    </div>
</template>

<script setup lang="ts">
import { ref, toRefs, reactive, computed, watch, onMounted } from 'vue'
const list = reactive([
    'icon-iconfontlist',
    'icon-iconfont31leimu',
    'icon-iconfonticonfontxinxi',
    'icon-iconfontdizhi',
    'icon-iconfontwo',
    'icon-wenjianjia',
    'icon-navicon-zhgl'
])

const itemClick = (e: Event) => {}
const hoverItem = ref<Number>()
const itemMousemove = (e: Event, index: number) => {
    hoverItem.value = index
    console.log(hoverItem.value)
}
const dockMouseleave = (e: Event) => {
    hoverItem.value = 10000
}
const resetScale = () => {}
</script>

<style scoped lang="less">
.mac {
    width: 100%;
    height: 70px;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    .dock {
        --scale: 1;
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
        .item:hover .iconfont {
            position: relative;
            top: -30px;

            scale: 1.5;
        }
        .item:hover + .item .iconfont {
            position: relative;
            top: -20px;

            scale: 1.2;
        }
        li:has(+ .hoverClass) .iconfont {
            position: relative;
            top: -20px;

            scale: 1.2;
        }
        .item {
            width: 70px;
            height: 100px;
            cursor: default;
            display: flex;
            justify-content: center;
            align-items: center;
            transition-delay: 210ms;
            position: relative;
            margin: 0 13px;
            cursor: pointer;
            box-sizing: border-box;
            &::after {
                content: '';
                width: 70px;
                height: 70px;
                position: absolute;
                bottom: -20px;
                left: 0;
                z-index: -1;
            }
            .iconfont {
                width: 100%;
                height: 70px;
                text-align: center;
                line-height: 70px;
                background: hotpink;
                border-radius: 8px;
                transition-duration: 210ms;
                font-size: calc(2rem * var(--scale));
                color: #fff;
            }
            .loading {
                animation: 1s loading ease-in infinite;
            }
        }
    }
}

@keyframes loading {
    0%,
    100% {
        transform: translateY(0px);
    }

    60% {
        transform: translateY(-40px);
    }
}
@keyframes itemIcon {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
    100% {
        transform: translateY(-30px);
    }
}
</style>
